<!doctype html>



  


<html class="theme-next muse use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>









<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  

  

  

  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.1" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="Linux命令," />








  <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?v=5.1.1" />






<meta name="description" content="&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;Linux系统的route命令用于显示和操作IP路由表（show / manipulate the IP routing table）。要实现两个不同的子网之间的通信，需要一台连接两个网络的路由器，或者同时位于两个网络的网关来实现。在Linux系统中，设置路由通常是为了解决以下问题：该Linux系统在一">
<meta name="keywords" content="Linux命令">
<meta property="og:type" content="article">
<meta property="og:title" content="Linux 命令- route">
<meta property="og:url" content="https://hcldirgit.github.io/2017/09/03/2. Linux 命令/55. Linux 命令- route/index.html">
<meta property="og:site_name" content="失落的乐章">
<meta property="og:description" content="&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;Linux系统的route命令用于显示和操作IP路由表（show / manipulate the IP routing table）。要实现两个不同的子网之间的通信，需要一台连接两个网络的路由器，或者同时位于两个网络的网关来实现。在Linux系统中，设置路由通常是为了解决以下问题：该Linux系统在一">
<meta property="og:locale" content="zh-Hans">
<meta property="og:updated_time" content="2017-09-01T08:37:00.897Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Linux 命令- route">
<meta name="twitter:description" content="&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;Linux系统的route命令用于显示和操作IP路由表（show / manipulate the IP routing table）。要实现两个不同的子网之间的通信，需要一台连接两个网络的路由器，或者同时位于两个网络的网关来实现。在Linux系统中，设置路由通常是为了解决以下问题：该Linux系统在一">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Muse',
    sidebar: {"position":"left","display":"post","offset":12,"offset_float":0,"b2t":false,"scrollpercent":false},
    fancybox: true,
    motion: true,
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="https://hcldirgit.github.io/2017/09/03/2. Linux 命令/55. Linux 命令- route/"/>





  <title>Linux 命令- route | 失落的乐章</title>
</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  




<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
            (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
          m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
  ga('create', '85*****1', 'auto');
  ga('send', 'pageview');
</script>


  <script type="text/javascript">
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "https://hm.baidu.com/hm.js?87980c**************99ec5e26fb5";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>











  
  
    
  

  <div class="container sidebar-position-left page-post-detail ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">失落的乐章</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle">技术面前，永远都是学生。</p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-message">
          <a href="/message" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-external-link"></i> <br />
            
            留言
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
    <link itemprop="mainEntityOfPage" href="https://hcldirgit.github.io/2017/09/03/2. Linux 命令/55. Linux 命令- route/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="失落的乐章">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/0.png">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="失落的乐章">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">Linux 命令- route</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2017-09-03T01:57:34+08:00">
                2017-09-03
              </time>
            

            

            
          </span>

          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    <div class="post-body" itemprop="articleBody">

      
      

      
        <p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Linux系统的route命令用于显示和操作IP路由表（show / manipulate the IP routing table）。要实现两个不同的子网之间的通信，需要一台连接两个网络的路由器，或者同时位于两个网络的网关来实现。在Linux系统中，设置路由通常是为了解决以下问题：该Linux系统在一个局域网中，局域网中有一个网关，能够让机器访问Internet，那么就需要将这台机器的IP地址设置为Linux机器的默认路由。要注意的是，直接在命令行下执行route命令来添加路由，不会永久保存，当网卡重启或者机器重启之后，该路由就失效了；可以在/etc/rc.local中添加route命令来保证该路由设置永久有效。</p>
<h2 id="1．命令格式"><a href="#1．命令格式" class="headerlink" title="1．命令格式"></a>1．命令格式</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">route [-f] [-p] [Command [Destination] [mask Netmask] [Gateway] [metric Metric]] [<span class="keyword">if</span> Interface]]</div></pre></td></tr></table></figure>
<h2 id="2．命令功能"><a href="#2．命令功能" class="headerlink" title="2．命令功能"></a>2．命令功能</h2><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Route命令是用于操作基于内核ip路由表，它的主要作用是创建一个静态路由让指定一个主机或者一个网络通过一个网络接口，如eth0。当使用”add”或者”del”参数时，路由表被修改，如果没有参数，则显示路由表当前的内容。</p>
<h2 id="3．命令参数"><a href="#3．命令参数" class="headerlink" title="3．命令参数"></a>3．命令参数</h2><ul>
<li>-c 显示更多信息</li>
<li>-n 不解析名字</li>
<li>-v 显示详细的处理信息</li>
<li>-F 显示发送信息</li>
<li>-C 显示路由缓存</li>
<li>-f 清除所有网关入口的路由表。 </li>
<li><p>-p 与 add 命令一起使用时使路由具有永久性。</p>
</li>
<li><p>add:添加一条新路由。</p>
</li>
<li>del:删除一条路由。</li>
<li>-net:目标地址是一个网络。</li>
<li>-host:目标地址是一个主机。</li>
<li>netmask:当添加一个网络路由时，需要使用网络掩码。</li>
<li>gw:路由数据包通过网关。注意，你指定的网关必须能够达到。</li>
<li>metric：设置路由跳数。</li>
<li>Command 指定您想运行的命令 (Add/Change/Delete/Print)。 </li>
<li>Destination 指定该路由的网络目标。 </li>
<li>mask Netmask 指定与网络目标相关的网络掩码（也被称作子网掩码）。 </li>
<li>Gateway 指定网络目标定义的地址集和子网掩码可以到达的前进或下一跃点 IP 地址。 </li>
<li>metric Metric 为路由指定一个整数成本值标（从 1 至 9999），当在路由表(与转发的数据包目标地址最匹配)的多个路由中进行选择时可以使用。 </li>
<li>if Interface 为可以访问目标的接口指定接口索引。若要获得一个接口列表和它们相应的接口索引，使用 route print 命令的显示功能。可以使用十进制或十六进制值进行接口索引。</li>
</ul>
<h2 id="4．使用实例"><a href="#4．使用实例" class="headerlink" title="4．使用实例"></a>4．使用实例</h2><h3 id="实例1：显示当前路由"><a href="#实例1：显示当前路由" class="headerlink" title="实例1：显示当前路由"></a>实例1：显示当前路由</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>命令</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">route</div><div class="line">route -n</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>输出</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div></pre></td><td class="code"><pre><div class="line">[root@localhost ~]<span class="comment"># route</span></div><div class="line">Kernel IP routing table</div><div class="line">Destination     Gateway         Genmask         Flags Metric Ref    Use Iface</div><div class="line">192.168.120.0   *               255.255.255.0   U     0      0        0 eth0</div><div class="line">e192.168.0.0     192.168.120.1   255.255.0.0     UG    0      0        0 eth0</div><div class="line">10.0.0.0        192.168.120.1   255.0.0.0       UG    0      0        0 eth0</div><div class="line">default         192.168.120.240 0.0.0.0         UG    0      0        0 eth0</div><div class="line">[root@localhost ~]<span class="comment"># route -n</span></div><div class="line">Kernel IP routing table</div><div class="line">Destination     Gateway         Genmask         Flags Metric Ref    Use Iface</div><div class="line">192.168.120.0   0.0.0.0         255.255.255.0   U     0      0        0 eth0</div><div class="line">192.168.0.0     192.168.120.1   255.255.0.0     UG    0      0        0 eth0</div><div class="line">10.0.0.0        192.168.120.1   255.0.0.0       UG    0      0        0 eth0</div><div class="line">0.0.0.0         192.168.120.240 0.0.0.0         UG    0      0        0 eth0</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>说明</strong></p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;第一行表示主机所在网络的地址为192.168.120.0，若数据传送目标是在本局域网内通信，则可直接通过eth0转发数据包;</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;第四行表示数据传送目的是访问Internet，则由接口eth0，将数据包发送到网关192.168.120.240 </p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;其中Flags为路由标志，标记当前网络节点的状态。</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>Flags标志说明：</strong></p>
<ul>
<li>U Up表示此路由当前为启动状态</li>
<li>H Host，表示此网关为一主机</li>
<li>G Gateway，表示此网关为一路由器</li>
<li>R Reinstate Route，使用动态路由重新初始化的路由</li>
<li>D Dynamically,此路由是动态性地写入</li>
<li>M Modified，此路由是由路由守护程序或导向器动态修改</li>
<li>! 表示此路由当前为关闭状态</li>
</ul>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;备注：</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;route -n (-n 表示不解析名字,列出速度会比route 快)</p>
<h3 id="实例2：添加网关-设置网关"><a href="#实例2：添加网关-设置网关" class="headerlink" title="实例2：添加网关/设置网关"></a>实例2：添加网关/设置网关</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>命令</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">route add -net 224.0.0.0 netmask 240.0.0.0 dev eth0</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>输出</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div></pre></td><td class="code"><pre><div class="line">[root@localhost ~]<span class="comment"># route add -net 224.0.0.0 netmask 240.0.0.0 dev eth0</span></div><div class="line">[root@localhost ~]<span class="comment"># route</span></div><div class="line">Kernel IP routing table</div><div class="line">Destination     Gateway         Genmask         Flags Metric Ref    Use Iface</div><div class="line">192.168.120.0   *               255.255.255.0   U     0      0        0 eth0</div><div class="line">192.168.0.0     192.168.120.1   255.255.0.0     UG    0      0        0 eth0</div><div class="line">10.0.0.0        192.168.120.1   255.0.0.0       UG    0      0        0 eth0</div><div class="line">224.0.0.0       *               240.0.0.0       U     0      0        0 eth0</div><div class="line">default         192.168.120.240 0.0.0.0         UG    0      0        0 eth0</div><div class="line">[root@localhost ~]<span class="comment">#</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>说明</strong></p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;增加一条 到达244.0.0.0的路由</p>
<h3 id="实例3：屏蔽一条路由"><a href="#实例3：屏蔽一条路由" class="headerlink" title="实例3：屏蔽一条路由"></a>实例3：屏蔽一条路由</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>命令</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">route add -net 224.0.0.0 netmask 240.0.0.0 reject</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>输出</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div></pre></td><td class="code"><pre><div class="line">[root@localhost ~]<span class="comment"># route add -net 224.0.0.0 netmask 240.0.0.0 reject</span></div><div class="line">[root@localhost ~]<span class="comment"># route</span></div><div class="line">Kernel IP routing table</div><div class="line">Destination     Gateway         Genmask         Flags Metric Ref    Use Iface</div><div class="line">192.168.120.0   *               255.255.255.0   U     0      0        0 eth0</div><div class="line">192.168.0.0     192.168.120.1   255.255.0.0     UG    0      0        0 eth0</div><div class="line">10.0.0.0        192.168.120.1   255.0.0.0       UG    0      0        0 eth0</div><div class="line">224.0.0.0       -               240.0.0.0       !     0      -        0 -</div><div class="line">224.0.0.0       *               240.0.0.0       U     0      0        0 eth0</div><div class="line">default         192.168.120.240 0.0.0.0         UG    0      0        0 eth0</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>说明</strong></p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;增加一条屏蔽的路由，目的地址为 224.x.x.x 将被拒绝</p>
<h3 id="实例4：删除路由记录"><a href="#实例4：删除路由记录" class="headerlink" title="实例4：删除路由记录"></a>实例4：删除路由记录</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>命令</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">route del -net 224.0.0.0 netmask 240.0.0.0</div><div class="line">route del -net 224.0.0.0 netmask 240.0.0.0 reject</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>输出</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div></pre></td><td class="code"><pre><div class="line">[root@localhost ~]<span class="comment"># route</span></div><div class="line">Kernel IP routing table</div><div class="line">Destination     Gateway         Genmask         Flags Metric Ref    Use Iface</div><div class="line">192.168.120.0   *               255.255.255.0   U     0      0        0 eth0</div><div class="line">192.168.0.0     192.168.120.1   255.255.0.0     UG    0      0        0 eth0</div><div class="line">10.0.0.0        192.168.120.1   255.0.0.0       UG    0      0        0 eth0</div><div class="line">224.0.0.0       -               240.0.0.0       !     0      -        0 -</div><div class="line">224.0.0.0       *               240.0.0.0       U     0      0        0 eth0</div><div class="line">default         192.168.120.240 0.0.0.0         UG    0      0        0 eth0</div><div class="line">[root@localhost ~]<span class="comment"># route del -net 224.0.0.0 netmask 240.0.0.0</span></div><div class="line">[root@localhost ~]<span class="comment"># route</span></div><div class="line">Kernel IP routing table</div><div class="line">Destination     Gateway         Genmask         Flags Metric Ref    Use Iface</div><div class="line">192.168.120.0   *               255.255.255.0   U     0      0        0 eth0</div><div class="line">192.168.0.0     192.168.120.1   255.255.0.0     UG    0      0        0 eth0</div><div class="line">10.0.0.0        192.168.120.1   255.0.0.0       UG    0      0        0 eth0</div><div class="line">224.0.0.0       -               240.0.0.0       !     0      -        0 -</div><div class="line">default         192.168.120.240 0.0.0.0         UG    0      0        0 eth0</div><div class="line">[root@localhost ~]<span class="comment"># route del -net 224.0.0.0 netmask 240.0.0.0 reject</span></div><div class="line">[root@localhost ~]<span class="comment"># route</span></div><div class="line">Kernel IP routing table</div><div class="line">Destination     Gateway         Genmask         Flags Metric Ref    Use Iface</div><div class="line">192.168.120.0   *               255.255.255.0   U     0      0        0 eth0</div><div class="line">192.168.0.0     192.168.120.1   255.255.0.0     UG    0      0        0 eth0</div><div class="line">10.0.0.0        192.168.120.1   255.0.0.0       UG    0      0        0 eth0</div><div class="line">default         192.168.120.240 0.0.0.0         UG    0      0        0 eth0</div><div class="line">[root@localhost ~]<span class="comment">#</span></div></pre></td></tr></table></figure>
<h3 id="实例5：删除和添加设置默认网关"><a href="#实例5：删除和添加设置默认网关" class="headerlink" title="实例5：删除和添加设置默认网关"></a>实例5：删除和添加设置默认网关</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>命令</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">route del default gw 192.168.120.240</div><div class="line">route add default gw 192.168.120.240</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>输出</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div></pre></td><td class="code"><pre><div class="line">[root@localhost ~]<span class="comment"># route del default gw 192.168.120.240</span></div><div class="line">[root@localhost ~]<span class="comment"># route</span></div><div class="line">Kernel IP routing table</div><div class="line">Destination     Gateway         Genmask         Flags Metric Ref    Use Iface</div><div class="line">192.168.120.0   *               255.255.255.0   U     0      0        0 eth0</div><div class="line">192.168.0.0     192.168.120.1   255.255.0.0     UG    0      0        0 eth0</div><div class="line">10.0.0.0        192.168.120.1   255.0.0.0       UG    0      0        0 eth0</div><div class="line">[root@localhost ~]<span class="comment"># route add default gw 192.168.120.240</span></div><div class="line">[root@localhost ~]<span class="comment"># route</span></div><div class="line">Kernel IP routing table</div><div class="line">Destination     Gateway         Genmask         Flags Metric Ref    Use Iface</div><div class="line">192.168.120.0   *               255.255.255.0   U     0      0        0 eth0</div><div class="line">192.168.0.0     192.168.120.1   255.255.0.0     UG    0      0        0 eth0</div><div class="line">10.0.0.0        192.168.120.1   255.0.0.0       UG    0      0        0 eth0</div><div class="line">default         192.168.120.240 0.0.0.0         UG    0      0        0 eth0</div><div class="line">[root@localhost ~]<span class="comment">#</span></div></pre></td></tr></table></figure>
      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        

      
    </div>

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/Linux命令/" rel="tag"># Linux命令</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2017/09/03/2. Linux 命令/16. Linux 命令- which/" rel="next" title="Linux 命令- which">
                <i class="fa fa-chevron-left"></i> Linux 命令- which
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2017/09/03/2. Linux 命令/71. Linux 命令- awk/" rel="prev" title="Linux 命令- awk">
                Linux 命令- awk <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          
  <div class="comments" id="comments">
    
  </div>


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap" >
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="/images/0.png"
               alt="失落的乐章" />
          <p class="site-author-name" itemprop="name">失落的乐章</p>
           
              <p class="site-description motion-element" itemprop="description">失落的乐章的Blog</p>
          
        </div>
        <nav class="site-state motion-element">

          
            <div class="site-state-item site-state-posts">
              <a href="/">
                <span class="site-state-item-count">627</span>
                <span class="site-state-item-name">日志</span>
              </a>
            </div>
          

          

          
            
            
            <div class="site-state-item site-state-tags">
              <a href="/tags/index.html">
                <span class="site-state-item-count">38</span>
                <span class="site-state-item-name">标签</span>
              </a>
            </div>
          

        </nav>

        

        <div class="links-of-author motion-element">
          
            
              <span class="links-of-author-item">
                <a href="https://github.com/hcldirgit" target="_blank" title="GitHub">
                  
                    <i class="fa fa-fw fa-github"></i>
                  
                  GitHub
                </a>
              </span>
            
          
        </div>

        
        

        
        

        


      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#1．命令格式"><span class="nav-number">1.</span> <span class="nav-text">1．命令格式</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#2．命令功能"><span class="nav-number">2.</span> <span class="nav-text">2．命令功能</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#3．命令参数"><span class="nav-number">3.</span> <span class="nav-text">3．命令参数</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#4．使用实例"><span class="nav-number">4.</span> <span class="nav-text">4．使用实例</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#实例1：显示当前路由"><span class="nav-number">4.1.</span> <span class="nav-text">实例1：显示当前路由</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#实例2：添加网关-设置网关"><span class="nav-number">4.2.</span> <span class="nav-text">实例2：添加网关/设置网关</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#实例3：屏蔽一条路由"><span class="nav-number">4.3.</span> <span class="nav-text">实例3：屏蔽一条路由</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#实例4：删除路由记录"><span class="nav-number">4.4.</span> <span class="nav-text">实例4：删除路由记录</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#实例5：删除和添加设置默认网关"><span class="nav-number">4.5.</span> <span class="nav-text">实例5：删除和添加设置默认网关</span></a></li></ol></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy; 
  <span itemprop="copyrightYear">2017</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">失落的乐章</span>
</div>


<div class="powered-by">
  由 <a class="theme-link" href="https://hexo.io">Hexo</a> 强力驱动
</div>

<div class="theme-info">
  主题 -
  <a class="theme-link" href="https://github.com/iissnan/hexo-theme-next">
    NexT.Muse
  </a>
</div>


        

        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.1"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.1"></script>



  
  

  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.1"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.1"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.1"></script>



  


  




	





  





  





  






  





  

  

  

  

  

  

</body>
</html>
